import 'package:proj_sfv/domain/UserVo.dart';
import 'package:proj_sfv/http/api.dart';

class Video {
  String videoId;
  String videoName;
  String videoUrl;
  int likeCount;
  int authorId;
  DateTime submitTime;
  String tags;
  String description;
  String profileUrl;
  UserVo userVo;


  Video(this.videoId, this.videoName, this.videoUrl, this.likeCount,
      this.authorId, this.submitTime, this.tags, this.description, this.profileUrl);

  Video.test(): videoName = "测试", videoId = "测试Id", videoUrl = "http://192.168.31.44:5244/p/sfv/%E6%97%B6%E5%85%89%E7%9A%84%E5%B2%B8%E4%B8%8A%E4%BA%BA%E6%9D%A5%E4%BA%86%E5%8F%88%E8%B5%B0@%E9%97%B7%"
      "E7%8C%AA.mp4?sign=BGXzjIqqTASM4xlYz_WvawHzIc7vlCEq-JQd4iG7dkc=:0", likeCount = 10,
  authorId = 1, submitTime = DateTime(2023), tags = "#1#2#3", description = "描述";

  Video.fromJson(Map<String, dynamic> data) {
    videoId = data['videoId'];
    description = data['description'];
    videoName = data['videoName'];
    videoUrl = Uri.http(cosHost3, '${data['videoId']}.mp4').toString();
    likeCount = data['likeCount'];
    authorId = data['authorId'];
    submitTime = DateTime.parse(data['submitTime']);
    tags = data['tags'];
    profileUrl = Uri.http(cosHost3, '${data['profileUrl']}.jpeg').toString();
  }

  Video.plain(): videoName = "加载中", videoId = "0", videoUrl = "", likeCount = 0, authorId = 0,
    submitTime = DateTime(2023), tags = "#", description = ""; // 空白Video

  @override
  String toString() {
    print('videoId: $videoId videoName: $videoName videoUrl: $videoUrl likeCount: $likeCount authorId: '
        '$authorId submitTime: $submitTime tags: $tags description: $description');
  }
}